You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sites hosted on GitHub Pages with custom domains have duplicate content at both username.github.io and customdomain.com, causing SEO issues. Adding canonical URLs tells search engines which URL is authoritative.
Changes
layouts/partials/header.html: Add canonical <link> tag using Hugo's .Permalink (which derives from baseURL). Supports existing relcanonical front matter for page-specific overrides.
layouts/_default/single.html: Remove duplicate canonical handling (now centralized in header.html).
Usage
Set your custom domain in hugo.yaml:
baseURL: https://customdomain.com/
All pages automatically get canonical URLs pointing to your custom domain. Individual pages can override via front matter:
---
relcanonical: /some/other/path
---
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
publish.twitter.com
Triggering command: /tmp/hugo hugo --themesDir ../.. (dns block)
Triggering command: /tmp/hugo hugo (dns block)
Triggering command: /tmp/hugo hugo --renderToMemory (dns block)
If you need me to access, download, or install something from one of these locations, you can either:
Configure Actions setup steps to set up my environment, which run before the firewall is enabled
Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Feature Request: support custom domains</issue_title>
<issue_description>I have tried to set up a custom domain for a personal GitHub page. It works smoothly but I noticed some SEO problems because of the duplicate content at username.github.io and customdomain.com
The internet suggests the following solution:
add to the head
I considered modifying just my fork of the theme, but I am now wondering if there are other places where
the custom domain should be added.
It is also unclear why there are two different parameters for the site URL: baseURL in hugo.yaml and openGraph.url.
Is there any case where they should differ from each other?
Since this may be a common situation, adding an option to the theme to support custom domains may be worth adding.
</issue_description>
Comments on the Issue (you are @copilot in this section)
@BernatBC
Hi @maiani, sorry for the late response.
I also have a custom domain, and I don't have any problems. I just added my custom domain into `hugo.yaml`, and followed the guide on github pages.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot Do we need <meta http-equiv="refresh" content="0; URL=https://customdomain.com/">?
No, the <meta http-equiv="refresh"> tag is not needed. The <link rel="canonical"> tag is the correct solution for the SEO duplicate content issue - it tells search engines which URL is authoritative without redirecting users. A meta refresh would forcibly redirect visitors, which isn't necessary since GitHub Pages serves the same content on both domains. The canonical tag lets search engines know which URL to index while users can still access the site from either URL.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sites hosted on GitHub Pages with custom domains have duplicate content at both
username.github.ioandcustomdomain.com, causing SEO issues. Adding canonical URLs tells search engines which URL is authoritative.Changes
layouts/partials/header.html: Add canonical<link>tag using Hugo's.Permalink(which derives frombaseURL). Supports existingrelcanonicalfront matter for page-specific overrides.layouts/_default/single.html: Remove duplicate canonical handling (now centralized in header.html).Usage
Set your custom domain in
hugo.yaml:All pages automatically get canonical URLs pointing to your custom domain. Individual pages can override via front matter:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
publish.twitter.com/tmp/hugo hugo --themesDir ../..(dns block)/tmp/hugo hugo(dns block)/tmp/hugo hugo --renderToMemory(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.